import { Column, Entity, Unique } from 'typeorm';
import { CommonEntity } from './common.entity'
import { StatusEnum } from '../enums/status.enum';

@Entity('access')
// @Unique('module_name_delete_at', ['title', 'deletedAt'])
// @Unique('action_name_delete_at', ['actionName', 'deletedAt'])
export class AccessEntity extends CommonEntity {
  @Column({
    type: 'tinyint',
    nullable: true,
    name: 'type',
    comment: '类型1:表示模块,2:表示菜单,3:表示接口(API)',
  })
  type: string;

  @Column({
    type: 'varchar',
    nullable: true,
    length: 50,
    name: 'module_name',
    comment: '标题名称',
  })
  title: string;

  @Column({
    type: 'varchar',
    nullable: true,
    length: 100,
    name: 'path',
    comment: 'url地址',
  })
  path: string;

  @Column({
    type: 'varchar',
    nullable: true,
    length: 100,
    name: 'icon',
    comment: '小图标',
  })
  icon: string;
  
  @Column({
    type: 'varchar',
    nullable: true,
    length: 100,
    name: 'name',
    comment: '路由名称',
  })
  name: string;

  @Column({
    type: 'int',
    nullable: false,
    default: 0,
    name: 'parent_id',
    comment: '父模块id',
  })
  parentId: number;

  @Column({
    type: 'int',
    nullable: false,
    default: 1,
    name: 'sort_id',
    comment: '排序',
  })
  sortId: number;

  @Column({
    type: 'tinyint',
    nullable: true,
    default: 1,
    name: 'status',
    comment: '状态,0表示禁止,1表示正常',
  })
  status: StatusEnum;

  @Column({
    type: 'varchar',
    nullable: true,
    length: 100,
    name: 'description',
    comment: '描述',
  })
  description: string;
}